﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;

namespace MuaBanLike.com
{
    public partial class MainWindow : Window
    {
        System.Windows.Forms.NotifyIcon ni;
        //private System.Windows.Forms.ContextMenuStrip mainMenu;
        //private System.Windows.Forms.ToolStripMenuItem startItem;
        //private System.Windows.Forms.ToolStripMenuItem stopItem;
        //private System.Windows.Forms.ToolStripMenuItem exitItem;

        private void initMenuContext()
        {
            ni = new System.Windows.Forms.NotifyIcon();
            ni.Icon = new System.Drawing.Icon("likenhanh.ico");
            ni.Text = m_mainWeb.ToString();
            ni.Visible = true;
            /*
            this.mainMenu = new System.Windows.Forms.ContextMenuStrip();
            this.startItem = new System.Windows.Forms.ToolStripMenuItem("&Start");
            this.startItem.Image = System.Drawing.Image.FromFile("Play_48x48.png");
            this.stopItem = new System.Windows.Forms.ToolStripMenuItem("S&top");
            this.stopItem.Image = System.Drawing.Image.FromFile("Stop_48x48.png");
            this.exitItem = new System.Windows.Forms.ToolStripMenuItem("E&xit");
            this.exitItem.Image = System.Drawing.Image.FromFile("exit.ico");

            // Initialize contextMenu
            mainMenu.Items.Add(startItem);
            mainMenu.Items.Add(stopItem);
            mainMenu.Items.Add(exitItem);

            this.startItem.Click += new System.EventHandler(this.onStart);
            this.stopItem.Click += new System.EventHandler(this.onStop);
            this.exitItem.Click += new System.EventHandler(this.onExit);
            // Set up how the form should be displayed. 
            ni.ContextMenuStrip = mainMenu;
             * */
            ni.BalloonTipText = m_mainWeb.ToString();
            ni.BalloonTipTitle = "Welcome";
            ni.ShowBalloonTip(1000);
            
            ni.DoubleClick +=
            delegate(object sender, EventArgs args)
            {
                this.Close();
            };

            this.ShowInTaskbar = false;
        }


        private void onExit(object Sender, EventArgs e)
        {
            // Close the form, which closes the application. 
            this.Close();
        }

        private void onStart(object Sender, EventArgs e)
        {
            try
            {
                //If You Want to define a defualt URI then you can define like below...
                MainBrowser.Source = m_mainWeb;              
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }

        private void onStop(object Sender, EventArgs e)
        {
            // Close the form, which closes the application. 
            this.Close();
        }

    }
}
